package cn.nabaixin.mine;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.Toast;
import cn.nabaixin.R;
import cn.nabaixin.latest.SaySth;
import cn.nabaixin.setting.SettingActivity;
/**
 * "我的"模块界面
 * @author ZWH
 *
 */
public class MineActivity extends Activity {
	private ListView lv;
	private SimpleAdapter sa;
	private List<Map<String, Object>> data;
	private Context c;
	
	//菜单项
	public final int MENU_REFRESH = 1;
	public final int MENU_SETTING = 3;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mine);
		
		c = MineActivity.this;
		initView();
		initData();
	}
	
	private void initView(){
		lv = (ListView) findViewById(R.id.mine_detailsList);
	}
	
	private void initData(){
		String titles[] = new String[]{"签到信息", "记录/照片", "我的关注", "我的粉丝", "找人"};
		
		data = new ArrayList<Map<String,Object>>();
		
		for(int i=0; i<titles.length; i++){
			HashMap<String, Object> item = new HashMap<String, Object>();
			item.put("title", titles[i]);
			data.add(item);
		}
		
		sa = new SimpleAdapter(c, data, R.layout.mine_list_item,
				new String[]{"title"}, new int[]{R.id.mine_infoTitle});
		lv.setAdapter(sa);
	}
	
	//添加菜单
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		menu.add(0, MENU_REFRESH, 0, "刷新").setIcon(R.drawable.menu_refresh);
		menu.add(0, MENU_SETTING, 3, "设置").setIcon(R.drawable.menu_setting);
		return super.onCreateOptionsMenu(menu);
	}
	//处理菜单点击
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		int itemId = item.getItemId();
		switch (itemId) {
		case MENU_REFRESH:
			Toast.makeText(c, "MENU_REFRESH", 0).show();
			return true;
		case MENU_SETTING:
			Intent intent2 = new Intent(c, SettingActivity.class);
			startActivity(intent2);
			return true;
		default:
			return super.onOptionsItemSelected(item);
		}
		
	}
}
